//    Copyright (C) Kherty.  All rights reserved.
using System.Windows.Media;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    /// <summary>
    /// Specifies that the drawing should stretch its container
    /// </summary>
    public class StretchModeProperties : FillModeProperties
    {
        private RelativeRectangle fillRect;

        public RelativeRectangle FillRectangle
        {
            get { return fillRect; }
            set { fillRect = value; }
        }


        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("stretch"))
            {
                fillRect = c.ReadOptionalElementAs<RelativeRectangle>("fillRect");
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("stretch"))
            {
                c.WriteOptionalElementAs(fillRect, "fillRect");
            }
        }

        public override void Apply(ImageBrush brush)
        {
            brush.Stretch = System.Windows.Media.Stretch.Fill; //\\rect...
        }
    }
}